package com.laycoding.consumer.controller;

import com.laycoding.consumer.service.IResultInterface;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;


import java.util.List;

/**
 * created with IntelliJ IDEA.
 *
 * @author: guidada
 * @date: 2021/05/12/10:17
 * @description:
 */
@RestController
@RequestMapping("/order/data")
public class UserCenterController {

    @Value("${server.port}")
    private Integer port;
    @Autowired
    private IResultInterface iResultInterface;

    @HystrixCommand(fallbackMethod = "fallbackGetResult")
    @GetMapping("/{id}")
    public String getTodayStatistic(@PathVariable("id") Integer id) {
        return iResultInterface.getResult(id);
    }

    public String fallbackGetResult(Integer id){
        return "这里进入熔断器的默认值"+id;
    }

}
